﻿//========================================
// All rights reserved (C) 2017-2100
// CLR 版本：	4.0.30319.42000
// 命名空间:	SFJDManagement
// 文 件 名：	FrameworkElementDevelop
// 作    者：	WooG
// 联系方式：	wooglle@163.com
// 创建时间：	2017/11/9 21:06:59
//========================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace SFJDManagement
{
    static class FrameworkElementDevelop
    {
        public static string GetValue(this FrameworkElement frameworkElement)
        {
            string b = "";
            Type type = frameworkElement.GetType();
            if (type == typeof(TextBlock))
            {
                b = (frameworkElement as TextBlock).Text;
            }
            else if (type == typeof(TextBox))
            {
                b = (frameworkElement as TextBox).Text;
            }
            else if (type == typeof(CheckBox))
            {
                b = (bool)(frameworkElement as CheckBox).IsChecked ? "true" : "false";
            }
            else if (type == typeof(ComboBox))
            {
                b = (frameworkElement as ComboBox).SelectedValue.ToString();
            }
            else
            {
                try
                {
                    b = (frameworkElement as ComboBox).SelectedValue.ToString();
                }
                catch { }
            }
            return b;
        }
    }
}
